<?php
//销毁用户
define('IN_TG',true);
include("includes/common.inc.php");
if(isset($_GET['id']))
{

    $tgid = intval($_GET['id']);
    $sql = "select tg_id from tg_user where tg_id = $tgid and tg_username='{$_SESSION['username']}' limit 1";
    $res1 = _fetch_array($sql);
    $arr=array();
    //判断用户是否存在
    if(is_array($res1))
    {
        $sql="delete from tg_user where tg_id = $tgid";
        $reres = _query($sql);
        _query("delete from tg_dir where tg_username = '{$_SESSION['username']}'");
        _query("delete from tg_article where tg_username = '{$_SESSION['username']}'");
        _query("delete from tg_photo_commend where tg_username = '{$_SESSION['username']}'");
        _query("delete from tg_photo where tg_username = '{$_SESSION['username']}'");
        _query("delete from tg_flower where tg_touser='{$_SESSION['username']}' or tg_fromuser='{$_SESSION['username']}'");
        _query("delete from tg_friend where tg_touser='{$_SESSION['username']}' or tg_fromuser='{$_SESSION['username']}'");
        _query("delete from tg_message where tg_touser='{$_SESSION['username']}' or tg_fromuser='{$_SESSION['username']}'");
        //销毁Session，跳转登录
        _session_destroy();
        _unsetcookies();
        header('Location:login.php');
    }
    else
    {
        _alert_back("你没有权销毁用户");
    }
}
else
{
    _alert_back("请不要非法操作");
}
?>